﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CookComputing.XmlRpc;
using JohnnySins.Code;

namespace JohnnySins
{
    public partial class WordPressTest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            Blog.BlogInfo newBlogPost = default(Blog.BlogInfo);
            newBlogPost.title = tbTitle.Text;
            newBlogPost.description = tbDescription.Text;

            Blog.IgetCatList categories = (Blog.IgetCatList)XmlRpcProxyGen.Create(typeof(Blog.IgetCatList));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)categories;

            clientProtocol.Url = tbBlogAddress.Text;
            string result = "";
            try
            {
                result = categories.NewPage(1, tbBlogUser.Text, tbBlogPassword.Text, newBlogPost, 1);
                
                tbTitle.Text = "";
                tbDescription.Text = "";
                lblMessage.Text = result;
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message + Environment.NewLine + ex.StackTrace;
            }  
            
        }
    }
}